import React, { FC, useContext } from "react";
import { reeducerContext } from "./table";
const TableList: FC = () => {
  const { state, dispatch } = useContext(reeducerContext);
  return (
    <>
      <div>列表的显示</div>
      <div>
        {state.map((item) => {
          return (
            <div key={item.id}>
              {item.id}-----{item.name} ----
              <button
                onClick={() => {
                  dispatch({
                    type: "delete",
                    payload: item.id,
                  });
                }}
              >
                delete
              </button>
            </div>
          );
        })}
      </div>
    </>
  );
};

export default TableList;
